New function to translate a string with translate_func. (#135740)
authorMatthias Clasen <maclas@gmx.de>
Thu, 6 May 2004 04:25:45 +0000 (04:25 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 6 May 2004 04:25:45 +0000 (04:25 +0000)
Thu May  6 00:24:11 2004  Matthias Clasen  <maclas@gmx.de>

* gtk/gtkactiongroup.h:
* gtk/gtkactiongroup.c (gtk_action_group_translate_string):
New function to translate a string with translate_func.
(#135740)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/ChangeLog
docs/reference/gtk/gtk-sections.txt
gtk/gtkactiongroup.c
gtk/gtkactiongroup.h

index 15ea51f1b84df8a9ae4fb89b2aefb64da8cf4463..577a3bba4ce40ab933d3e7a5eaedff5ff6bf8f92 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu May  6 00:24:11 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkactiongroup.h: 
+       * gtk/gtkactiongroup.c (gtk_action_group_translate_string): 
+       New function to translate a string with translate_func.
+       (#135740)
+       
 Thu May  6 00:02:21 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcombobox.c (gtk_combo_box_get_wrap_width): 
index 15ea51f1b84df8a9ae4fb89b2aefb64da8cf4463..577a3bba4ce40ab933d3e7a5eaedff5ff6bf8f92 100644 (file)
@@ -1,3 +1,10 @@
+Thu May  6 00:24:11 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkactiongroup.h: 
+       * gtk/gtkactiongroup.c (gtk_action_group_translate_string): 
+       New function to translate a string with translate_func.
+       (#135740)
+       
 Thu May  6 00:02:21 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcombobox.c (gtk_combo_box_get_wrap_width): 
index 15ea51f1b84df8a9ae4fb89b2aefb64da8cf4463..577a3bba4ce40ab933d3e7a5eaedff5ff6bf8f92 100644 (file)
@@ -1,3 +1,10 @@
+Thu May  6 00:24:11 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkactiongroup.h: 
+       * gtk/gtkactiongroup.c (gtk_action_group_translate_string): 
+       New function to translate a string with translate_func.
+       (#135740)
+       
 Thu May  6 00:02:21 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcombobox.c (gtk_combo_box_get_wrap_width): 
index 15ea51f1b84df8a9ae4fb89b2aefb64da8cf4463..577a3bba4ce40ab933d3e7a5eaedff5ff6bf8f92 100644 (file)
@@ -1,3 +1,10 @@
+Thu May  6 00:24:11 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkactiongroup.h: 
+       * gtk/gtkactiongroup.c (gtk_action_group_translate_string): 
+       New function to translate a string with translate_func.
+       (#135740)
+       
 Thu May  6 00:02:21 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkcombobox.c (gtk_combo_box_get_wrap_width): 
index abfc3d5629d5495cd36b53b14ec1d9bd48dcd087..444d5a689555d7869ed80bf0c0958bf3e342328c 100644 (file)
@@ -1,3 +1,7 @@
+Thu May  6 00:22:38 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtk-sections.txt: Add gtk_action_group_translate_string()
+
 Thu May  6 00:04:03 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtk-sections.txt: Add missing getters.
index 1c02125f3649e5b1f8e82f0b441be25b80f70127..f9c975a0bfd7cdb7fdb017284eca6f97301eed5a 100644 (file)
@@ -175,6 +175,7 @@ gtk_action_group_add_radio_actions
 gtk_action_group_add_radio_actions_full
 gtk_action_group_set_translate_func
 gtk_action_group_set_translation_domain
+gtk_action_group_translate_string
 <SUBSECTION Standard>
 GTK_TYPE_ACTION_GROUP
 GTK_ACTION_GROUP
index f265bd2c298a2007ca3a2e4efaa65426519914cb..1072db14b44a0336ffa393237228f4c43c7a91a0 100644 (file)
@@ -738,15 +738,10 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group,
    * gtk_action_group_add_..._actions_full() functions.
    */
   guint i;
-  GtkTranslateFunc translate_func;
-  gpointer translate_data;
   SharedData *shared_data;
 
   g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
 
-  translate_func = action_group->private_data->translate_func;
-  translate_data = action_group->private_data->translate_data;
-
   shared_data = g_new0 (SharedData, 1);
   shared_data->ref_count = 1;
   shared_data->data = user_data;
@@ -758,16 +753,8 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group,
       const gchar *label;
       const gchar *tooltip;
 
-      if (translate_func)
-       {
-         label = translate_func (entries[i].label, translate_data);
-         tooltip = translate_func (entries[i].tooltip, translate_data);
-       }
-      else
-       {
-         label = entries[i].label;
-         tooltip = entries[i].tooltip;
-       }
+      label = gtk_action_group_translate_string (action_group, entries[i].label);
+      tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
 
       action = gtk_action_new (entries[i].name,
                               label,
@@ -847,15 +834,10 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup       *action_group,
    * gtk_action_group_add_..._actions_full() functions.
    */
   guint i;
-  GtkTranslateFunc translate_func;
-  gpointer translate_data;
   SharedData *shared_data;
 
   g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
 
-  translate_func = action_group->private_data->translate_func;
-  translate_data = action_group->private_data->translate_data;
-
   shared_data = g_new0 (SharedData, 1);
   shared_data->ref_count = 1;
   shared_data->data = user_data;
@@ -867,16 +849,8 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup       *action_group,
       const gchar *label;
       const gchar *tooltip;
 
-      if (translate_func)
-       {
-         label = translate_func (entries[i].label, translate_data);
-         tooltip = translate_func (entries[i].tooltip, translate_data);
-       }
-      else
-       {
-         label = entries[i].label;
-         tooltip = entries[i].tooltip;
-       }
+      label = gtk_action_group_translate_string (action_group, entries[i].label);
+      tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
 
       action = gtk_toggle_action_new (entries[i].name,
                                      label,
@@ -968,32 +942,19 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup      *action_group,
    * gtk_action_group_add_..._actions_full() functions.
    */
   guint i;
-  GtkTranslateFunc translate_func;
-  gpointer translate_data;
   GSList *group = NULL;
   GtkRadioAction *first_action = NULL;
 
   g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
 
-  translate_func = action_group->private_data->translate_func;
-  translate_data = action_group->private_data->translate_data;
-
   for (i = 0; i < n_entries; i++)
     {
       GtkRadioAction *action;
       const gchar *label;
       const gchar *tooltip; 
 
-      if (translate_func)
-       {
-         label = translate_func (entries[i].label, translate_data);
-         tooltip = translate_func (entries[i].tooltip, translate_data);
-       }
-      else
-       {
-         label = entries[i].label;
-         tooltip = entries[i].tooltip;
-       }
+      label = gtk_action_group_translate_string (action_group, entries[i].label);
+      tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
 
       action = gtk_radio_action_new (entries[i].name,
                                     label,
@@ -1087,6 +1048,36 @@ gtk_action_group_set_translation_domain (GtkActionGroup *action_group,
                                       g_free);
 } 
 
+/**
+ * gtk_action_group_translate_string:
+ * @action_group: a #GtkActionGroup
+ * @string: a string
+ *
+ * Translates a string using the specified translate_func(). This
+ * is mainly intended for language bindings. 
+ *
+ * Returns: the translation of @string
+ *
+ * Since: 2.6
+ **/
+gchar *
+gtk_action_group_translate_string (GtkActionGroup *action_group,
+                                  const gchar    *string)
+{
+  GtkTranslateFunc translate_func;
+  gpointer translate_data;
+
+  g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+
+  translate_func = action_group->private_data->translate_func;
+  translate_data = action_group->private_data->translate_data;
+
+  if (translate_func)
+    return translate_func (string, translate_data);
+  else
+    return string;
+}
+
 /* Protected for use by GtkAction */
 void
 _gtk_action_group_emit_connect_proxy  (GtkActionGroup *action_group,
index 5d91dccf076f879dba8026083af7c9ec65b62e51..26c50410e691951cb48d323655bdcff413007425 100644 (file)
@@ -160,6 +160,8 @@ void            gtk_action_group_set_translate_func      (GtkActionGroup       *
                                                           GtkDestroyNotify      notify);
 void            gtk_action_group_set_translation_domain  (GtkActionGroup       *action_group,
                                                           const gchar          *domain);
+gchar          *gtk_action_group_translate_string        (GtkActionGroup       *action_group,
+                                                         const gchar          *string);
 
 /* Protected for use by GtkAction */
 void _gtk_action_group_emit_connect_proxy    (GtkActionGroup *action_group,